package com.ruoyi.project.system.mapper;

import com.ruoyi.project.system.domain.DtBaseinfo;
import com.ruoyi.project.system.domain.DtFlow;
import com.ruoyi.project.system.domain.IncomingLogin;
import com.ruoyi.project.system.domain.dto.AddressBook;
import com.ruoyi.project.system.domain.dto.AppAuth;
import com.ruoyi.project.system.domain.dto.CallLog;
import com.ruoyi.project.system.domain.dto.TextMessage;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import java.util.List;
import java.util.Map;

/**
 * 通知公告表 数据层
 */
public interface DtPhoneMapper {

    IncomingLogin queryLoginAccount(Integer queryId);

    int addLoginAccount(IncomingLogin incomingLogin);

    int updateLoginAccount(IncomingLogin incomingLogin);

    int addPhone(IncomingLogin incomingLogin);

    @Select("select id from dt_baseinfo where queryId = #{queryId}")
    Integer queryDtBaseInfo(Integer queryId);

    @Insert("insert into dt_baseinfo(queryId, createTime) values (#{queryId},now())")
    int addDtBaseInfo(Integer queryId);

    @Insert("insert into dt_flow(queryId, createTime) values (#{queryId},now())")
    int addDtFlow(Integer queryId);

    @Update("update dt_query_list SET isIncome = '1' where queryId = #{queryId}")
    int updateDtQueryListIsIncome(Integer queryId);

    @Update("update dt_flow set ${item} = '1', updateTime = now() where queryId = #{queryId}")
    int updateDtFlow(String item, Integer queryId);

    IncomingLogin login(String account);

    String accountState(Integer queryId);

    int insertAppAuth(List<AppAuth> appAuths);

    int insertCallLog(List<CallLog> callLogs);

    int insertTextMessage(List<TextMessage> textMessages);

    int insertAddressBook(List<AddressBook> addressBooks);

    DtFlow queryDtFlow(Integer queryId);

    String baseInfoFlow(Integer queryId, String item);

    @Select("select IDFrontAuth from dt_baseinfo where queryId = #{queryId}")
    String baseInfoIDFrontAuth(Integer queryId);

    Map<String, String> incomeHeadBaseInfo(Integer queryId);





    int setDevice(Integer queryId, String info);

    int setLocation(Integer queryId, String info);

    int setBaseInfo(Integer queryId, String baseInfo);

    int setCardImg(Integer queryId, String frontImg, String backImg, String handImg);

    int setCardAuthImg(Integer queryId, String cardAuth, String authImg);

    int setThreeEleAuth(Integer queryId, String threeElementAuth);



    DtBaseinfo baseInfo(Integer queryId);

    String relation(Integer queryId);

    List<AppAuth> appList(AppAuth appAuth);

    List<TextMessage> textMessageList(TextMessage textMessage);

    List<AddressBook> addressBookList(AddressBook addressBook);

    List<CallLog> callLogList(CallLog callLog);

    List<CallLog> baseInfoCallLogList(@Param("list_") List<String> list, @Param("queryId") Integer queryId);

    int insertFiles(String item);

    @Select("SELECT id, filename FROM files WHERE queryId = #{queryId} ORDER BY createTime DESC LIMIT 1")
    Map<String, Object> getFile(Integer queryId);

    @Select("SELECT id, filename FROM files WHERE state = '1' ORDER BY createTime ASC LIMIT 1")
    Map<String, Object> getFirstFile();

    @Update("UPDATE files set queryId = #{queryId}, state = '0' WHERE id = #{id}")
    int setFile(Integer queryId, String id);

    @Select("SELECT COUNT(*) FROM files WHERE state = '1'")
    int filesCount();
}
